<--- If you double click on this icon, the bookmark file "Script Index" will be opened.
Introduction
As Jedit3.0 is the AppleScript scriptable* application, you can control Jedit3.0 from the AppleScript program you made with the "Script Editor." You can also register your script programs in the "Macro" menu of Jedit3.0 as your own custom menu. You can also control other AppleScript scriptable applications from a macro menu item you made.
(For details of the "Macro" menu, see "Chapter 8, 8-1 Macro Menu".)
Using AppleScript commands supported by Jedit, you can launch/quit Jedit, open/close/save documents of Jedit, edit text of them and so on.
The purpose of this chapter is mainly to explain the specifications of Jedit's AppleScript, not AppleScript in general. If you are not familiar with the fundamentals of AppleScript, please see some guide book. You can also get useful information from the following web sites.
http://www.apple.com/applescript/ (in English)
http://www.asep.apple.co.jp/Techdoc/AppleScript/ (in Japanese)
* You can execute most of operations that are concerned with text editing by using Jedit's commands of AppleScript but there are some operations that cannot be controlled by AppleScript. And Jedit is not an AppleScript recordable application as far as text editing is concerned.
Compatibility with Jedit2.0
The former version, Jedit2.0 also supports AppleScript. In most cases you can use your scripts of Jedit2.O also with Jedit3.0 if you change the application name in the "tell" statement that includes "Jedit2.0" as shown below.
Please note the following differences between Jedit2.0 and Jedit3.0 concerning AppleScript .Å@
1) Jedit2.0 supports both Japanese and English dialect in AppleScript. But the AppleScript of MacOS8.5 or higher does not support Japanese dialect. So Jedit3.0 supports only those commands written with Japanese dialect which Jedit2.0 supported, but new commands of Jedit3.0 cannot be written with Japanese dialect. We recommend that you write your new scripts only with English dialect.
2) As Jedit3.0 is the multi-styled text editor, you can use new properties of font, size, style and color of each object such as byte, character, word, line, paragraph and selection. You can deal with the contents of these properties by means of "get" and "set" commands. The information you get from the properties of some object by the use of "get" command will be the style information of the first character of that object.
While the style properties of the document object of Jedit2.0 are those of the whole document,these properties of Jedit3.0 are the default styles of the document.
When you use commands such as "copy", "paste", "cut", "move" and "insert", you can also deal with the style data in addition to the text data.
3) While the values of the properties defined in the macro scripts of Jedit2.0 will be always initialized when they are executed, these values of Jedit3.0 will be saved and used in the next execution.
4) The application object of Jedit3.0 has the"version" property. You can know your Jedit's version from the contents of this property.
5) You can do "Find All" of the menu "Search" also from AppleScript by the use of the parameter "batch" of the "find" command of Jedit3.0.
6) The specification of "as" parameter of "save" command is changed. If you have the script you made with Jedit2.0 and use it with Jedit3.0 , please take account of this change.
The so-called "object(class)"s of Jedit3.0 you can control with AppleScript are "application", "window", "document", "byte", "character", "word", "line", "paragraph" and "selection".
The name of the default font used for the printing
fontSize small integer
The default font size
printing fontSize small integer
The font size for the printing.
style text style info
The default text style
fore color 'RGB '
The default foreground (character) color of the document.
back color 'RGB '
The background color of the document
auto indent boolean
If true, the auto indent is on.
tab width small integer
The tab width of the document (points)
word wrap small integer
0: word-wrap is off
1: normal word-wrap
2: hanging word-wrap in the Japanese text
line width small integer
The line width (points). If zero, it follows the window width
line space small integer
The space between lines of the edit window (points)
kanji type ShiftJis/Jis/Euc/NecJis/AcosJis/CisJis/Unicode/Utf8
The type of encoding.
lf type mac/unix/dos
The type of line break.
html coloring boolean
If true, the HTML coloring is on.
infinite undo boolean
If true, the multiple undo is on.
"byte" object
A "byte" object is a object whose length or position is expressed by byte. In English text, the byte object and the character object are same, but in the languages of 2-bytes characters such as Japanese, the byte object and the character object are not exactly the same object. The 2-bytes character such as kanji is counted as one character.
The offset of a character object from the beginning of the document
(the first byte has offset 1)
line number integer [r/o]
The line number of a character object from the beginning of the
document (the first line has number 1)
paragraph number integer [r/o]
The paragraph number of a character object from the beginning of
the document (the first paragraph has number 1)
font international text
The font name
fontSize small integer
The font size
style text style info
The text style
fore color 'RGB '
The foreground (character) color
"word" object
A "word" object is a string separated by white spaces ( space codes, return codes and tab codes). In the Japanese text, the word object may be meaningless because the spaces are not used for the word separators.
The offset of a word object from the beginning of the document
(the first byte has offset 1)
line number integer [r/o]
The line number of a word object from the beginning of the
document (the first line has number 1)
paragraph number integer [r/o]
The paragraph number of a word object from the beginning of
the document (the first paragraph has number 1)
font international text
The font name
fontSize small integer
The font size
style text style info
The text style
fore color 'RGB '
The foreground (character) color
"line" object
A "line" object is a physical line of the document window. If you change the document width from the "Document Width..." of the menu "Format", the contents of the line objects will also be changed.
The offset of a selection object from the beginning of the document
(the first byte has offset 1)
line number integer [r/o]
The line number of a selection from the beginning of the
document (the first line number has number 1)
paragraph number integer [r/o]
The paragraph number of a selection from the beginning of
the document (the first paragraph has number 1)
font international text
The font name
fontSize small integer
The font size
style text style info
The text style
fore color 'RGB '
The foreground (character) color
Commands (Events)
"run" command
run variable OR Reference
Open the application file in the same way as when you double click on it from the Finder Desktop.
run application "Jedit3"
Each time the "run" command is executed, the OpenApplication event will be sent to the target application to open a new window.
"launch" command
launch variable OR Reference
Launch the application file in the same way as when you double click on it from the Finder Desktop.
launch application "Jedit3"
Unlike the "run" command, the "launch" command will not open a new window when the application is already running.
"make" command
make
new type class -- the class of the new element
[at location reference] -- the location at which to insert the element
[with data anything] -- the initial data of the element
[with properties record]
-- the initial values of the properties of the new element
Result: reference -- reference to the new element
Open a new document or a new window. You can not use this command to objects other than the window and document object.
sample:
make new document
make new window
"open" command
open reference -- the object(s) to open
[kanji type ShiftJis/Jis/Euc/NecJis/AcosJis/CisJis/Unicode/Utf8]
The encoding type
[lf type mac/unix/dos]
The line break type
The "open" command opens the document file of Jedit3.0.
The following script will open the file "MyDoc" in the "documents" folder in the "Macintosh HD":
tell application "Jedit3"
open file "Macintosh HD:documents:MyDoc"
end tell
You can specify the type of kanji encoding in the parameter "kanji type".
Available encoding types are "ShiftJis", "Jis", "Euc", "NecJis", "AcosJis", "CisJis", "Unicode", "Utf8". You can also specify the line break type in the parameter "lf". Available line break types are "mac"(cr), "unix"(lf), "dos"(cr+lf).
tell application "Jedit3"
open file "Macintosh HD:documents:MyDoc" with kanji type Unicode
end tell
If you omit the encoding or the line break parameter, Jedit will judge the encoding or line break type automatically.
"print" command
print alias -- list of objects to print
The "print" command will print the document of Jedit3.0 in the same way as when you select the "Print One" of the menu "File". The "print" command can also print the objects such as file, selection, paragraph, line and so on.
print the file "MyDoc"
tell application "Jedit3"
print file "Macintosh HD:documents:MyDoc"
end tell
print the lines from 3 to 5 of the selection of the document 1
tell application "Jedit3"
tell document 1
print lines 3 thru 5 of selection
end tell
end tell
"save" command
save reference -- Objects to save.
[in alias]
The file in which to save the object(s)
[as same/Jedit3/TextOnly/SimpleText/ReadOnly]
The file type of the document in which to save the data
[kanji type ShiftJis/Jis/Euc/NecJis/AcosJis/CisJis/Unicode/Utf8]
The type of encoding
[lf type mac/unix/dos]
The line break type
The "save" command will save the object that you specify in the reference.
In the parameter "in", you can specify a file in which you want to save the target document in the same as you select a file after you choose the "Save As..." of the menu "File". Omit the parameter "in" if you want to save the target document in the same way as you save it by choosing "Save" of the menu "File".
You can also specify the file type in the parameter "as". The file types are "same" (same as the source file), "Jedit3" (Jedit3.0 normal file), "TextOnly" (Jedit3.0 file without the resource fork), "SimpleText" (SimpleText file) and "ReadOnly" (SimpleText Read-only file).
You can specify the type of encoding in the parameter "kanji type". The type of encodings are "ShiftJis", "Jis", "Euc", "NecJis", "AcosJis", "CisJis", "Unicode", "Utf8".
You can also specify the type of line break in the parameter "lf" . The type of line breaks are "mac"(cr), "unix"(lf), "dos"(cr+lf).
The following script will save the whole contents of the current document into the file "HD:documents:MyDoc" with unix type of line break and unicode type of encoding.
tell application "Jedit3"
save document 1 in file "HD:documents:MyDoc" kanji type Unicode lf type unix
end tell
The following script will save the highlighting area of the current document into the file "HD:documents:MyDoc" with unix type of line break and unicode type of encoding.
tell application "Jedit3"
save selection of document 1 in file "HD:documents:MyDoc" kanji type Unicode lf type unix
end tell
"revert" command
revert reference -- object to revert
The "revert" command will let the document revert to the original state in which you last saved it. You can use this command only for document objects.
tell application "Jedit3"
revert document 1
end tell
"close" command
close reference -- the objects to close
[saving yes/no/ask]
Specifies whether or not changes should be saved before closing
[in alias]
The file in which to save the object
The "close" command will close the document or window. You can specify the way to save a document in the parameter "saving". If you omit the parameter "saving", the document will be closed in the same way as you close it by choosing the "Close" of the menu "File". In this case, if the document you close is not saved, the save dialog box asking its file name will appear. You can also assign the alias of the file in which you save with "in" parameter.
The following script will save document "MyDoc" in the file "MyFile" and then close it.
tell application "Jedit3"
close document "MyDoc" saving yes in file "MyFile"
end tell
"quit" command
quit
The "quit" command will quit Jedit3.0 in the same way as when you quit it by choosing the "Quit" of the menu "File".
There is no parameters with this command.
"data size" command
data size reference
The object whose data size is to be returned
Result: integer
The size of the object in bytes
The "data size" command will return the byte size of the specified object. In the case of the line or paragraph objects, the returned size will contain the number of the line breaks.
The following script will count the byte size of the paragraph 3 of the current document.
tell application "Jedit3"
data size of paragraph 3 of document 1
end tell
The same value will be returned if you replace the "data size" in this script with "count bytes".
"get" command
get reference
The object whose data is to be returned
Result: anything
The data of the object
The "get" command will return the contents or properties of the objects you specify.
The following script will get the content of the first word of the paragraph 3 of the current document.
tell application "Jedit3"
get word 1 of paragraph 3 of document 1
end tell
The following script will get the font size of the current selection
tell application "Jedit3"
get fontSize of selection of document 1
end tell
The following script will copy the contents of the current document to the result variable
tell application "Jedit3"
get document 1
end tell
The following script will get the style of the third word in the highlighted area of the current document.
tell application "Jedit3"
tell document 1
get style of word 3 of selection
end tell
end tell
"set" command
set reference
The object to change
to anything
The new value
You can use the "set" command widely to set new values, contents, properties, cursor positions, highlighted areas and so on.
The following script will replace the third word of the paragraph 3 to the string "abcd".
tell application "Jedit3"
set word 3 of paragraph 3 of document 1 to "abcd"
end tell
The following script will change the font of the highlighted area to "Chicago"
tell application "Jedit3"
set font of selection of document 1 to "Chicago"
end tell
The following script will set the cursor to the position before the first word of the paragraph 4
tell document 1 of application "Jedit3"
set selection to before word 1 of paragraph 4
end tell
You can use the prepositions of "before", "after" and "end" when you specify the insert position.
The following script will set the cursor to the end of the 4th paragraph (before the line break).
tell document 1 of application "Jedit3"
set selection to end of paragraph 4
end tell
The following script will move the cursor after the 4th paragraph (after the line break of the paragraph).
tell document 1 of application "Jedit3"
set selection to after paragraph 4
end tell
The following script will highlight all text of the 4th paragraph.
tell document 1 of application "Jedit3"
set selection to paragraph 4
end tell
The following script will select the lines from the first line to the third line.
tell document 1 of application "Jedit3"
set selection to line 1 thru 3
end tell
The following script will set the style of the 3rd word 3 in the selected text to the style of "bold" and "italic".
tell document 1 of application "Jedit3"
set style of word 3 of selection to { bold, italic }
end tell
The following script will set the style of the 3rd word in the selected text to the style "plain".
tell document 1 of application "Jedit3"
set style of word 3 of selection to plain
end tell
The following script will set the style of the 1st line to the style "bold" when the style of the 1st line is not "bold", and vice versa.
tell document 1 of application "Jedit3"
set style of line 1 to { bold, true }
end tell
"insert" command
insert reference
The object to be inserted
at location reference
The location at which to insert the object(s)
When you want to control the text editing operation of Jedit3.0, the "insert" command will be the most powerful tool. It has a wide range of uses.
You can insert or replace the various objects at any location you like. The "insert" command will also deal with the style information in addition to the text data.
You can also use the prepositions such as "before", "beginning of", "after" and "end" when you want to specify the insert position. Without this specification of the insert position, the object which the "at" parameter indicates will be replaced with the object which "reference" after the command "insert" indicates.
The following script will add the contents of the file "MyDoc" to the end of the current document.
tell application "Jedit3"
insert file "HD:Docs:MyDoc" at end of document 1
end tell
The following script will Insert the string "abcdefg" at the beginning of the current document
tell application "Jedit3"
insert "abcdedg" at beginning of document 1
end tell
The following script will replace the 3rd word with the string "abcdedg".
tell document 1 of application "Jedit3"
insert "abcdedg" at word 3
end tell
The following script will add the whole contents of the current document to end of the 2nd document.
tell application "Jedit3"
insert document 1 at end of document 2
end tell
The following script will add the 2nd word of the 3rd line of the current document at the end of the 2nd document.
tell application "Jedit3"
insert word 2 of line 3 of document 1 at end of document 2
end tell
The following script will add from the 2nd to 3rd paragraphs after the last paragraph.
tell document 1 of application "Jedit3"
insert (paragraph 2 Thru 3 ) at after the last paragraph
end tell
The following script will add the selected text area of the current document after the end of the 2nd document.
tell application "Jedit3"
insert the selection of document 1 at after the last paragraph of document 2
end tell
"delete" command
delete reference
The element to delete
The "delete" command will delete the object that you specify in "reference"
The following script will delete the second line of the current document.
tell application "Jedit3"
delete line 2 of document 1
end tell
"move" command
move reference
The object(s) to move
to location reference
The new location for the object(s)
The "move" command will move the object that you specify in "reference" to the new location. The "move" command is only valid in the same document. You can not move the object to other documents with this command.
The following script will move the selected object to the end of the 5th line. The following 2 scripts bring the same result.
tell document 1 of application "Jedit3"
move selection to line 5
end tell
or
tell document 1 of application "Jedit3"
move selection to end of line 5
end tell
The following script will move the 5th word of the 3rd paragraph to top of the 4th paragraph.
tell document 1 of application "Jedit3"
move word 5 of paragraph 3 to before paragraph 4
end tell
Move the selected object to end of the current document
tell application "Jedit3"
move selection of document 1 to end of document 1
end tell
or
tell application "Jedit3"
tell document 1
move selection to end of it
end tell
end tell
"find" command
find string
The string to search for
in reference
The object reference that you search for the string
[case sensitive boolean]
If true, will distinguish between capital and small letters
[zenkaku sensitive boolean]
If true, will distinguish between hankaku and zenkaku characters
[entire word boolean]
If true, will search for the string as one word
[wrap around boolean]
If true, will continue to search from the top of the document after
it reaches the end of the document.
[start at top boolean]
If true, will start searching at the beginning of the document
[reverse search boolean]
If true, will search in the backward direction, that is, from the
bottom to the top.
[grep boolean]
If true, will find in the regular expression mode
[batch boolean]
If true, will find in the batch mode (find all occurrences and mark
them into the bookmark list)
Result: boolean
If find the string, return true
The "find" command searches for a string in the object that you specify in the parameter "in". If you specify a document object in the parameter "in", Jedit will start searching from the current cursor position of the document.
If the object at the parameter "in" is not the document, Jedit will search the range of that object.
The values of the option parameters at the "find" command are only valid in your script and will not affect the settings of the "Find Settings" dialog. If you omit the option parameters, the values defined in the "Find Settings" dialog will be used in your script.
If you set the parameter "batch" to true, Jedit will search for all occurrences and the results will be listed in the mark list.
The following script will search the current document for the string "Jedit" as one word and without distinguishing between capital and small letters.
tell application "Jedit3"
find "Jedit" in document 1 with entire word without case sensitive
end tell
or
tell application "Jedit3"
tell document 1
find "Jedit" in it with entire word without case sensitive
end tell
end tell
Note that you should use "it" to indicate the "document 1" between the "tell document 1" statement and the"end tell" statement.
The following script will search the highlighted area of the current document for the string "Jedit" as one word and without distinguishing between capital and small letters.
tell application "Jedit3"
tell document 1
find "Jedit" in selection with entire word without case sensitive
end tell
end tell
The following script will search the highlighted area of the current document for all the occurrences of the string "Jedit".
tell application "Jedit3"
tell document 1
find "Jedit" in selection with batch
end tell
end tell
"replace" command
replace string
The string to search for and to be replaced
to string
The replacement string
in reference
The object reference that you search for the string
[case sensitive boolean]
If true, will distinguish between capital and small letters
[zenkaku sensitive boolean]
If true, will distinguish between hankaku and zenkaku characters
[entire word boolean]
If true, will search for the string as one word
[grep boolean]
If true, will find in the regular expression mode
Result: small integer
The number of the replacements
The "replace" command will replace strings in the object specified in the parameter "in". You can specify the object such as document, selection, paragraph and line in the parameter "in".
The values of the option parameters in the "replace" command are only valid in your script and will not affect the settings of the "Find Settings" dialog.
If you omit the option parameters, the values defined in the "Find Settings" dialog will be used in your script.
The following script will replace all the string "Jedit" with "Jedit3.0" in the highlighted text area of the current document.
tell application "Jedit3"
tell document 1
replace "Jedit" to "Jedit3.0" in selection
end tell
end tell
The following script will replace all the string "Jedit" to "Jedit3.0" in the current document.
tell application "Jedit3"
tell document 1
replace "Jedit" to "Jedit3.0" in it
end tell
end tell
"mark" command
mark reference
The object to mark
The "mark" command will list the mark of location of the objects in the bookmark list.
The following script will make the mark of location of the 10th line of the current document.
tell application "Jedit3"
tell document 1
mark line 10
end tell
end tell
The following script will make the mark of location of the highlighted area of the current document.
tell application "Jedit3"
mark selection of document 1
end tell
"count" command
count reference
The object whose elements are to be counted
each type class
The class of the elements to be counted.
Keyword 'each' is optional.
Result: integer
The number of elements
The "count" command will return the size of the object using the specified type class.
The following script will return the number of words of the first line of the current document.
tell application "Jedit3"
tell document 1
count words of line 1
end tell
end tell
or
tell application "Jedit3"
tell document 1
count line 1 each word
end tell
end tell
The following script will return the number of characters of the highlighted area of the current document.
tell application "Jedit3"
count characters of selection of document 1
end tell
"exists" command
exists reference
The object in question
Result: boolean
True if it exists, false if not
The command "exists" will examine the existence of the specified object. If the object is exists, it returns true in the "Result" variable.
The following script will query the existence of the 6th word in the highlighted text area of the current document.
tell application "Jedit3"
exists word 6 of selection of document 1
end tell
"cut" command
cut reference
The object to be cut and brought into the clipboard
The "cut" command will delete the specified object and copy it into the clipboard. The style information will also be copied to the clipboard. When the object you specify is a document, the selected area of the document will be "cut" instead of the whole document.
Note: If Jedit is not the front application, the "cut" command will delete the object but does not copy it into the clipboard. You should activate Jedit before you use this command.
The following script will cut the selected area of the current document. Both of the scripts will bring about the same result.
tell application "Jedit3"
activate
cut document 1
end tell
or
tell application "Jedit3"
activate
cut selection of document 1
end tell
The following script will cut the 4th line of the current document.
tell application "Jedit3"
activate
cut line 4 of document 1
end tell
"copy" command
copy reference
The source object to be copied
[to reference ]
The target location
The command "copy" will copy the specified object into the target location.
If you omit the "to" parameter, the object will be copied to the clipboard.
Note: If Jedit is not the front application, you can not copy the specified object into the clipboard. You should activate Jedit before you use this command.
The following script will copy the selected area of the current document to the clipboard in the same way as when you choose the "Copy" of the menu "Edit".
tell application "Jedit3"
activate
copy document 1
end tell
If you specify the location object with the parameter "to", the location object will be replaced with the source object.
The following script will replace the 3rd word of the 5th line of the current document with the string "abcdef".
tell document 1 of application "Jedit3"
copy "abcdef" to word 3 of line 5
end tell
The following script will bring the same result as the above script.
tell document 1 of application "Jedit3"
set (word 3 of line 5) to "abcdef"
end tell
The following script will replace the highlighted area with the string "abcdef"
tell document 1 of application "Jedit3"
copy "abcdef" to selection
end tell
"paste" command
paste reference of document object
The "paste" command will paste the contents of the clipboard to the highlighted area of the specified document object. You can use this command only for document objects.
The following script will paste the contents of the clipboard to the highlighted area of the current document.
tell application "Jedit3"
activate
paste document 1
end tell
"select" command
select reference
The object to select
The command "select" will select (highlight) the area of the specified object.
The following script will highlight from the 1st to 5th lines of the current document.
tell document 1 of application "Jedit3"
select line 1 thru 5
end tell
If you want to move the cursor, use "set selection" command instead.
The following script will move the cursor to the end of the 5th line.
tell document 1 of application "Jedit3"
set selection to end of line 5
end tell
"undo"/"redo" command
undo reference of the document
redo reference of the document
The command "undo"/"redo" will undo/redo the former operation in the same way as when you choose the "Undo"/"Redo" of the menu "Edit". You can use this command only for document objects.
The following script will undo the former operation done to the current document.
tell application "Jedit3"
undo document 1
end tell
"speak" command
speak reference
The object to speak
The command "speak" will read out the reference object according to the settings of the "Speech" panel of the "Preferences". Speech Manager and related files must be installed to make this function work.
(For details on speech settings, see "Manual Chapter 3 - 3.9 Speech.")
The following script will read out the selected text area of the current document.
tell application "Jedit3"
tell document 1
speak selection
end tell
end tell
"justify" command
justify reference
The object to format
[width integer]
The line width (in bytes)
[with prefix string]
The prefix string
[word wrap boolean]
If true, the word-wrap is on
[removing break boolean]
If true, will remove line breaks and indents before formatting lines
The “justify” command will format lines of the reference object in the same way as when you choose the "Format Lines" of the menu "Tools". If you specify the reference object smaller than a paragraph, the whole paragraph that contains that object will be formatted.
You can specify the byte width of each line in the parameter "width", the prefix string in the parameter "with prefix", whether or not to use "word-wrap" in the parameter "word wrap" and wheher or not to remove line breaks and indents in the parameter "removing break".
If you omit these parameters, the values defined in the "Format Lines" dialog which you can open from the "Format Setting" of the menu "Tools" will be used in your script.
The following script will format all lines of the current document to the width of 80 bytes with word-wrapping and without prefix.
tell application "Jedit3"
justify document 1 width 80 with prefix "" with word wrap
end tell
The following script will format from the 5th to 10th paragraphs of the current document to the width of 80 bytes with word-wrapping and adding the quote prefix ">".
tell application "Jedit3"
tell document 1
justify paragraph 5 thru 10 width 80 with prefix ">"
with word wrap
end tell
end tell
The following script will remove line breaks and indents from the selected text area and then format it to the width of 80 bytes with word-wrapping and adding the quote prefix ">".
tell application "Jedit3"
tell document 1
justify selection width 80 with prefix ">"
with word wrap with removing break
end tell
end tell
"remove break" command
remove break reference
The object to remove breaks
The command "remove break" will remove line breaks and indents of the specified object.
The following script will remove all line breaks and indents from the current document.
tell application "Jedit3"
remove break document 1
end tell
The following script will remove line breaks and indents from the current selected text area.
tell application "Jedit3"
remove break selection of document 2
end tell
The following script will remove line breaks and indents from the text area that extends from the 1st to 10th paragraph of the current document.
tell document 1 of application "Jedit3"
remove break paragraph 1 thru 10
end tell
"detab" command
detab reference
The object to detab
The "detab" command will replace tab codes with corresponding space codes in the specified object.
"entab" command
entab reference
The object to entab
The "entab" command will replace space codes with corresponding tab codes in the specified object.
"convert kanji space to ascii" command
convert kanji space to ascii reference
The object to convert
The "convert kanji space to ascii" command will replace 2-bytes kanji space codes to corresponding ASCII space codes in the specified object.
"toYomi" command
toYomi reference
The object to convert
The "toYomi" command will convert the Japanese kanji strings to the hiraganas. Language Analysis Manager (supported in MacOS8.5J or higher) must be installed to make this function work.
The following script will convert all kanji characters to the hiragana characters in the selected text area of the current document .
tell application "Jedit3"
tell document 1
toYomi selection
end tell
end tell
"toZenkaku" command
toZenkaku reference
the object to convert
[with cnvFlag string]
16 digit Hexadecimal string from the Conversion Setting Dialog
The "toZenkaku" command will convert the hanakaku characters into the zenkaku characters in the specified object. You can specify the details of the conversion in the "Hankaku to Zenkaku" dialog from the menu "Tools". You can also specify the details of the conversion in the parameter "with cnvFlag". The "cnvFlag" is a 16-digits hexadecimal string which you can copy from the "Hankaku to ZenKau" dialog.
(For details of the "cnvFlag", see "Chapter 7, 7-8 Conversion Menus".)
The following script will convert the hankaku numeric characters of the selected area to the zenkaku characters.
tell application "Jedit3"
tell document 1
toZenkaku selection with cnvFlag "4000000000000000"
end tell
end tell
"toHankaku" command
toHankaku reference
The object to convert
[with cnvFlag string]
16 digit Hexadecimal string from the Conversion Setting Dialog
The "toHankaku" command will convert the Zenakaku characters into the hankaku characters in the specified object. You can specify the details of the conversion by the "Zenkaku to Hankaku" dialog from the menu "Tools". You can also specify the details of the conversion in the parameter "with cnvFlag". The "cnvFlag" is a 16-digits hexadecimal string which you can copy from the "Zenkaku to Hankaku" dialog.
(For details of the "cnvFlag", see "Chapter 7, 7-8 Conversion Menus".)
The following script will convert the Zenkaku numeric characters of the selected area to the hankaku characters in the current document.
tell application "Jedit3"
tell document 1
toHankaku selection with cnvFlag "4000000000000000"
end tell
end tell
"convert kana to zenkaku" command
convert kana to zenkaku reference
The "convert kana to zenkaku" command will convert the hankaku kana characters of the reference into the zenkaku kana characters in the specified object. This command will bring the same result as the "toZenkaku" command with the cnvFlag of "1000003E00000000".
"convert ascii to hankaku" command
convert ascii to hankaku reference
The "convert ascii to hankaku" command will convert the zenkaku ASCII characters into the hankaku ASCII characters in the specified object. This command will bring the same result as the "toHankaku" command with the cnvFlag of "E0000001FFFFFFFE".
"remove tailing space" command
remove tailing space reference
The "remove tailing space" command will remove the unnecessary tailing spaces at the end of paragraphs in the reference.
The following script will remove the tailing spaces of the selected text area.
tell application "Jedit3"
tell document 1
remove tailing space selection
tell end
tell end
"toUnicode" command
toUnicode reference
The "toUnicode" command will convert the reference object into the Unicode hexadecimal expressions (\uxxxx).
"fromUnicode" command
fromUnicode reference
The "fromUnicode" command will let the Unicode hexadecimal expressions (\uxxxx) revert to the normal characters in the specified object.
"OpenURL" command
OpenURL reference
URL string or document
Result: boolean
will return true if the web page of the specified URL is opened
successfully,
The "OpenURL" command will start the default browser and open the web page of the specified URL. "Internet Config" must be installed to make this function work. The protocols of "http", "ftp", "mailto" and "file" are supported.
The following script will open the Matsumoto's web page "http://www.matsumoto.co.jp" with your default browser.
tell application "Jedit3"
OpenURL "http://www.matsumoto.co.jp"
end tell
The following script will open the URL of the cursor position of the current document with your default browser. If the cursor is located among the URL string, you don't need to select the whole URL string to make this script work.
tell application "Jedit3"
OpenURL document 1
end tell
"OpenDict" command
OpenDict reference
The word or the document to look up
Result: boolean
will return true if the dictionary is opened successfully.
The "OpenDict" command will look up the specified word in the dictionary that is registered in the "Word Service" of the menu "Tools". If more than one dictionaries are registered in the "Word Service" menu, the first dictionary in that menu will be used.
The following script will look up the word "meditation" in the dictionary.
tell application "Jedit3"
OpenDict "meditation"
end tell
The following script will look up the selected word of the current document in the dictionary.
tell application "Jedit3"
OpenDict document 1
end tell
"OpenChecker" command
OpenChecker reference
The object to check
with menu international text
The name of the checker which appears in the "Word Services" menu.
Result: boolean
If the checker is opened successfully, true will be returned
The "OpenChecker" command will check the spellings of the specified object using the spell checker of the parameter "with menu".
The following script will check the correctness of HTML of the current document using "JChecker" whose name is "Check HTML" in the "Word Service" menu.
tell application "Jedit3"
OpenChecker document 1 with menu "Check HTML"
end tell
You can use this command not only for checkers but also for dictionaries.
The following script will look up the selected word of the current document using the dictionary application whose name is "Jamming 2.8.1 PPC" in the "Word Service" menu.
tell application "Jedit3"
OpenChecker document 1 with menu "Jamming 2.8.1 PPC"
end tell
"preDialog"/"postDialog" command
preDialog
postDialog
You should use these commands before and after the statement which opens dialog boxes in your script. Otherwise, Jedit's selection control of windows will possibly be in disorder when your script ends.
Following example is using preDialog and postDialog commands before and after the "choose folder" command.
preDialog
try
copy (choose folder with prompt "Where is the folder?") to checkFolder
on error
postDialog
error number -128
end try
postDialog
Note that in the above example the "postDialog" command is used between "on error" and "error number -128" statements as well as after the "end try" statement .
"suspend" command
suspend
When you open some other application from your script, it sometimes happens that after this script ends you cannot use the TSM inline conversion mode with the document of Jedit. To avoid this trouble, we recommend that you use the "suspend" command before the statement of your script which will open other application.
In the following script, the "suspend" command is used before the statement which will open the "Internet Explorer".
tell application "Jedit3"
activate
save document 1
copy fileSpec of document 1 to FileName
suspend
tell application "Internet Explorer 4.5"
Activate
open FileName
end tell
end tell
"updateMacroMenu" command
updateMacroMenu
The "updateMacroMenu" command will update the "Macro" menu after you add or remove macro script files in the "Macro Menu Items" folder.
The following example script will replace all macro menu items with new macro menu items using the contents of the folder "another Macro Menu Items".
tell application "Jedit3"
get Jedit folder
copy (result as text) to temp
suspend
tell application "Finder"
activate
select folder "Macro Menu Items" of folder temp
set name of selection to "Old Macro Menu Items"
select folder "another Macro Menu Items" of folder temp
set name of selection to "Macro Menu Items"
select folder "Old Macro Menu Items" of folder temp
set name of selection to "another Macro Menu Items"